package com.edu.exam.entity.examination.paper;

import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 特殊考试计划实体类
 * 所属模块：E-01 考试执行模块
 * 对应数据库表：special_exam_plan
 *
 * <p>特殊考试计划实体类，存储特殊考试计划的基本信息和状态。
 * 用于管理非常规考试的安排，包括补考、重修考试、特殊需求考试等。</p>
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@Data
@EqualsAndHashCode(callSuper = false)
public class SpecialExamPlan {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "plan_no", length = 50, unique = true, nullable = false)
    private String planNo;

    @Column(name = "plan_name", length = 200, nullable = false)
    private String planName;

    @Column(name = "plan_type", length = 50, nullable = false)
    private String planType;

    @Column(name = "plan_status", length = 50, nullable = false)
    private String planStatus;

    @Column(name = "description", columnDefinition = "TEXT")
    private String description;

    @Column(name = "expected_start_date")
    private LocalDate expectedStartDate;

    @Column(name = "expected_end_date")
    private LocalDate expectedEndDate;

    @Column(name = "created_by", length = 64, nullable = false)
    private String createdBy;

    @CreationTimestamp
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    @Column(name = "updated_by", length = 64)
    private String updatedBy;

    @UpdateTimestamp
    @Column(name = "updated_time")
    private LocalDateTime updatedTime;

    @Version
    @Column(name = "version", nullable = false)
    private Integer version = 1;

    // 关联实体
    @OneToMany(mappedBy = "plan", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<PlanItem> planItems;

    @OneToMany(mappedBy = "plan", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<ConflictDetection> conflicts;
}